home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.021.Dynamo / dynamo.sample / sample.a < prev   
Encoding:
Text File  |  1990-06-24  |  8.1 KB  |  422 lines  |  [TEXT/MPS ]

  1. *******************************************************
  2. *                        *
  3. * Apple II 8-bit runtime sample exerciser.        *
  4. * Copyright (C) 1990 Apple Computer.        *
  5. * Version 3.1                    *
  6. *                        *
  7. * Written by Eric Soldan, Apple II DTS        *
  8. *                                                     *
  9. * Developer Technical Support Apple II Sample Code    *
  10. *                                                     *
  11. *******************************************************
  12.  
  13.         include    ':dynamo.includes:sys.equ'
  14.         include    ':dynamo.includes:rt.h'
  15.         include    ':dynamo.includes:rt.macros'
  16.  
  17.         include    'app.config'
  18.  
  19. *********************************************
  20.  
  21.         export    varspace
  22. varspace        PROC
  23.         ds.b    256
  24.         endp
  25.  
  26. ******************
  27.  
  28.         export    strspace
  29. strspace        PROC
  30.         export    strlens, maxstrlens, strlocs
  31. strlens        ds.b    numstrings
  32. maxstrlens    dc.b    maxstr1, maxstr2
  33. strlocs        dc.w    str1loc, str2loc
  34.         endp
  35.  
  36. ******************
  37.  
  38. part1        PROC
  39.         export    start
  40.         import    part2
  41.  
  42.         jsr    $C300        ;Initialize 80-col screen.
  43.         _writecr
  44.         jsr    home
  45.  
  46. start        lda    #0        ;Clear the variable space.
  47.         tax            ;This application does not
  48. @clearvars    sta    varspace,x    ;need to variables to be
  49.         inx            ;pre-cleared.
  50.         bne    @clearvars
  51.  
  52.         jmp    part2
  53.  
  54.         endp
  55.  
  56. ******************
  57.  
  58. part2        PROC
  59.  
  60.         _rtreset
  61.         _hibitchrs
  62.  
  63.         _write    '8-bit sample application demonstrating ',\
  64.             'macros and runtime.',13,\
  65.             'Copyright (C) 1990 by Apple Computer.',13,\
  66.             '<<< Version 3.1 >>>'
  67.  
  68.         _signed
  69.         _write    13,13,13,13,'  Testing signed output:  '
  70.         _decout    #-1
  71.         _unsigned
  72.         _write    13,'Testing unsigned output:  '
  73.         _decout    #-1
  74.  
  75.         _write    13,13,'  Testing 1-byte decimal output:  '
  76.         _decoutl    #-1
  77.         _write    13,'Testing variable decimal output:  '
  78.         _set    var1,#<123
  79.         _vdecout
  80.  
  81.         _write    13,13,'           hexpad default is to pad with 0''s:  '
  82.         _vhexout
  83.         _hexnopad
  84.         _write    13,'       Testing 2-byte hex output with no pad:  '
  85.         _hexout    #123
  86.         _hexpad    #32
  87.         _write    13,'Testing 2-byte hex output padded with spaces:  '
  88.         _hexout    #123
  89.  
  90.  
  91.         _hexpad    #'0'
  92.         _writecr
  93.         _write    13,'   Testing 1-byte hex output padded with 0''s:  '
  94.         _hexoutl    #15
  95.         _hexnopad
  96.         _write    13,'       Testing 1-byte hex output with no pad:  '
  97.         _hexoutl    #15
  98.         _hexpad    #32
  99.         _write    13,'Testing 1-byte hex output padded with spaces:  '
  100.         _hexoutl    #15
  101.         
  102.         jsr    nextPage
  103.  
  104.         _write    'Testing _addvar:  1234+5678='
  105.         _set    var2,#5678
  106.         _set    var1,#1234
  107.         _addvar    ,var2
  108.         _vdecout
  109.         _write    13,'  Testing _addl:  +123='
  110.         _addl    ,#123
  111.         _vdecout
  112.         _write    13,'   Testing _add:  +456='
  113.         _add    ,#456
  114.         _vdecout
  115.  
  116.         _write    13,13,'Testing _subvar:  5678-1234='
  117.         _set    var2,#1234
  118.         _set    var1,#5678
  119.         _subvar    ,var2
  120.         _vdecout
  121.         _write    13,'  Testing _subl:  -123='
  122.         _subl    ,#123
  123.         _vdecout
  124.         _write    13,'   Testing _sub:  -456='
  125.         _sub    ,#456
  126.         _vdecout
  127.  
  128.         _write    13,13,'Testing _mulvar:  12*345='
  129.         _set    var2,#345
  130.         _set    var1,#<12
  131.         _mulvar    ,var2
  132.         _vdecout
  133.         _write    13,'  Testing _mull:  *6='
  134.         _mull    ,#6
  135.         _vdecout
  136.         _write    13,'   Testing _mul:  *789='
  137.         _mul    ,#789
  138.         _vdecout
  139.         _write    '   (Overflow -- loss of high-order bytes.)'
  140.  
  141.         _write    13,13,'Testing _divvar:  65432/23='
  142.         _set    var2,#<23
  143.         _set    var1,#65432
  144.         _divvar    ,var2
  145.         _set    remainder
  146.         _vdecout    var1
  147.         _write    '  (Remainder='
  148.         _vdecout    remainder
  149.         _rtcout    #')'
  150.         _write    13,'  Testing _divl:  /34='
  151.         _divl    var1,#34
  152.         _set    remainder
  153.         _vdecout    var1
  154.         _write    '         (Remainder='
  155.         _vdecout    remainder
  156.         _rtcout    #')'
  157.         _write    13,'   Testing _div:  /321='
  158.         _div    var1,#321
  159.         _set    remainder
  160.         _vdecout    var1
  161.         _write    '         (Remainder='
  162.         _vdecout    remainder
  163.         _rtcout    #')'
  164.  
  165.         _write    13,13,'Testing dereferencing ($1234 means good):  $'
  166.         _set    var1,**@ptr1        ;var1 has address @ptr3 now.
  167.         _add    ,#<2            ;var1 has address @ptr3+2 now.
  168.         _vderef                ;var1 has address @ptr4 now.
  169.         _vderef                ;var1 has address @ptr5 now.
  170.         _vderef                ;var1 has value from @ptr5 now.
  171.         _vhexout
  172.         jmp    @past
  173.  
  174. @ptr1        dc.w    @ptr2
  175. @ptr2        dc.w    @ptr3
  176. @ptr3        dc.w    0,@ptr4
  177. @ptr4        dc.w    @ptr5
  178. @ptr5        dc.w    $1234
  179.  
  180. @past        jsr    nextPage
  181.  
  182.         _set    var1,#345
  183.         _set0    var1
  184.         _write    'Testing _set0:  '
  185.         _vdecout
  186.         _set    var2,#<2
  187.         _var    var1
  188.         _varcpy    ,var2
  189.         _write    13,'Testing _var and _varcpy (2 means good):  '
  190.         _vdecout
  191.         _set    var1,#345
  192.         _setl    ,#123
  193.         _write    13,'Testing _setl (123 means good):  '
  194.         _vdecout
  195.         _write    13,'Testing _setvars:  '
  196.         _setvars    var1,#123,var2,#456,var3,#789
  197.         _vdecout    var1
  198.         _rtcout    #','
  199.         _vdecout    var2
  200.         _rtcout    #','
  201.         _vdecout    var3
  202.  
  203.         _write    13,13,'  Testing _maxswap (signed):  '
  204.         _set    var1,#-123
  205.         _signed
  206.         _maxswap    var1,var2
  207.         _vdecout
  208.         _rtcout    #','
  209.         _vdecout    var2
  210.         _write    13,'Testing _maxswap (unsigned):  '
  211.         _unsigned
  212.         _maxswap    var1,var2
  213.         _signed
  214.         _vdecout
  215.         _rtcout    #','
  216.         _vdecout    var2
  217.  
  218.         _write    13,'Testing _minswap (unsigned):  '
  219.         _unsigned
  220.         _minswap    var1,var2
  221.         _signed
  222.         _vdecout
  223.         _rtcout    #','
  224.         _vdecout    var2
  225.         _write    13,'  Testing _minswap (signed):  '
  226.         _minswap    var1,var2
  227.         _vdecout
  228.         _rtcout    #','
  229.         _vdecout    var2
  230.         _unsigned
  231.  
  232.         _write    13,13,'Testing _vsgncmp:  -123<456?:  '
  233.         _setvars    var1,#-123,var2,#456
  234.         _vsgncmp    var1,var2
  235.         bcc    @a
  236.         _write    'no'
  237.         jmp    @b
  238. @a        _write    'yes'
  239. @b        _write    13,'   Testing _vcmp:  -123<456?:  '
  240.         _vcmp    var1,var2
  241.         bcc    @c
  242.         _write    'no'
  243.         jmp    @d
  244. @c        _write    'yes'
  245. @d        _write    13,' Testing _sgncmp:  -123<456?:  '
  246.         _sgncmp    var1,#456
  247.         bcc    @e
  248.         _write    'no'
  249.         jmp    @f
  250. @e        _write    'yes'
  251. @f        _write    13,'    Testing _cmp:  -123<456?:  '
  252.         _cmp    var1,#456
  253.         bcc    @g
  254.         _write    'no'
  255.         jmp    @h
  256. @g        _write    'yes'
  257. @h
  258.  
  259.         _readend    #0
  260.         _restore    #strdata
  261.         _readstr    str1
  262.         _prstr
  263.         _readstr    str2
  264.         _strval
  265.         _decout
  266.  
  267.         _readstr    str1
  268.         _prstr
  269.         _midstrval str2,#2
  270.         _decout
  271.  
  272.         _writecr
  273.         _readstr   str1
  274.         _prleftstr str1,#10
  275.         _prmidstr  str1,#10,#5
  276.         _prmidstr  str1,#15,#255
  277.  
  278.         _writecr
  279.         _readstr    str1
  280.         _leftstrcpy str2,str1,#15
  281.         _prstr
  282.         _midstrcpy  ,str1,#15,#5
  283.         _prstr
  284.         _midstrcpy  ,str1,#20
  285.         _prstr
  286.  
  287.         _writecr
  288.         _readstr    str1
  289.         _strcpy    str2,str1
  290.         _prstr
  291.  
  292.         _writecr
  293.         _readstr    str2
  294.         _readstr    str1
  295.  
  296.         _leftstrcat str2,str1,#10
  297.         _midstrcat  ,str1,#10,#5
  298.         _midstrcat  ,str1,#15
  299.         _prstr
  300.  
  301.         _writecr
  302.         _readstr    str1
  303.         _readstr    str2
  304.  
  305.         _strcat    str1,str2
  306.         _prstr
  307.  
  308.         jsr    nextPage
  309.  
  310.         _readstr    str1
  311.         ldy    #0
  312. @loop        cpy    strlens+str1
  313.         beq    @brkloop
  314.         tya
  315.         pha
  316.         _strchr
  317.         _rtcout
  318.         pla
  319.         tay
  320.         iny
  321.         bne    @loop
  322. @brkloop
  323.  
  324.         _litstr    str1,13,'Testing _litstr.'
  325.         _prstr
  326.         _write    13,'Testing _strloc:  str1 is at $'
  327.         _strloc    str1
  328.         _hexout
  329.  
  330.         _write    13,13,'Testing _rndseed:  value passed is:  $'
  331.         _hexnopad
  332.         _hexout    *rndl
  333.         _rndseed    *rndl
  334.         _write    13,13,'Testing _random (200 numbers from 0 to 99):',13,13
  335.         ldx    #10
  336. @loopx        stx    @tempx
  337.         ldy    #20
  338. @loopy        sty    @tempy
  339.         _random    #100        ;This random generator can not generate
  340.         _decout            ;a zero value.  This is okay, since you
  341.         lda    #','        ;can't declare a limit in 2 bytes which
  342.         ldy    @tempy        ;would give you this range.  (To get a
  343.         dey            ;high-end value of 65535, you would have
  344.         bne    @i        ;to have a limit of 65536.
  345.         lda    #13        ;Adjustments for the algorithm not
  346. @i        _rtcout            ;generating a 0 value have been made.
  347.         ldy    @tempy        ;1 is subtracted from the value, thus
  348.         dey            ;moving the problem value from 0 to 65535.
  349.         bne    @loopy        ;Since there is a limit on the 65535 value
  350.         ldx    @tempx        ;anyway, due to not being able to declare
  351.         dex            ;a limit or 65536, this works rather well.
  352.         bne    @loopx
  353.  
  354.         jsr    nextPage
  355.  
  356.         _write    13,'Testing array handling.'
  357.         _write    13,'The array is 2x512x2x4 words.'
  358.  
  359.         _array    #$4000,w,#2,#512,#2,#4
  360.  
  361.         _index    #<1,#379,#<1
  362.         _set    var1,#1234
  363.         _putw    ,#<3
  364.  
  365.         _index    ,#<73
  366.         _set    var1,#5678
  367.         _putw    ,#<4
  368.  
  369.         _write    13,13,'array(1,379,1,3)='
  370.         _index    ,#379,#<1
  371.         _getw    var1,#<3
  372.         _vdecout
  373.  
  374.         _write    13,'array(1,73,0,4)='
  375.         _index    ,#<73
  376.         _getw    var1,#<4
  377.         _vdecout
  378.  
  379.         jsr    nextPage
  380.  
  381.         jmp    start
  382. @tempx        dc.b    0
  383. @tempy        dc.b    0
  384.  
  385.  
  386. strdata        _cstr    13,13,'Testing _readend, _restore, ',\
  387.             '_readstr, and _strval:  '
  388.         _cstr    '12345'
  389.         _cstr    13,'Testing _midstrval:  '
  390.         _cstr    'Testing _prleftstr and _prmidstr.'
  391.         _cstr    'Testing _leftstrcpy and _midstrcpy.'
  392.         _cstr    'Testing _strcpy.'
  393.         _cstr    0,'Testing _leftstrcat and _midstrcat.'
  394.         _cstr    'Testing '
  395.         _cstr    '_strcat.'
  396.         _cstr    13,'Testing _strchr.'
  397.  
  398. nextPage        lda    #22
  399.         sta    cv
  400.         _write    13,'  <<< Press any key to go on (or ESC to quit). >>>'
  401.         bit    $C010
  402. @a        inc    rndl
  403.         bne    @b
  404.         inc    rndh
  405. @b        lda    $C000
  406.         bpl    @a
  407.         bit    $C010
  408.         cmp    #$9B
  409.         beq    @quit
  410.         jmp    home
  411. @quit        jsr    home
  412.         jsr    mli
  413.         dc.b    $65
  414.         dc.w    @quitlist
  415. @quitlist    dc.b    4
  416.         dc.w    0,0,0
  417.  
  418.         endp
  419.  
  420.         END
  421.  
  422.